package com.cd.form.jpa.domian;

import com.cd.common.domain.BaseDomain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;

@Data
@Entity
@Table(name = "db_form_auth",
        indexes = {
                @Index(name = "idx_form_id", columnList = "form_id"),
                @Index(name = "idx_user_id", columnList = "user_id") // 添加索引优化查询性能
        })
@NoArgsConstructor
@AllArgsConstructor

public class FormAuth extends BaseDomain {

    @EmbeddedId
    private FormAuthId id;

    // 如果需要单独访问 formId 和 userId，可以通过以下方式：
    public Long getFormId() {
        return this.id.getFormId();
    }

    public void setFormId(Long formId) {
        if (this.id == null) {
            this.id = new FormAuthId();
        }
        this.id.setFormId(formId);
    }

    public Long getUserId() {
        return this.id.getUserId();
    }

    public void setUserId(Long userId) {
        if (this.id == null) {
            this.id = new FormAuthId();
        }
        this.id.setUserId(userId);
    }
}